﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv=content-type content="text/html; charset=UTF-8">
    <script src="../libs/jquery-1.3.2.min.js" type="text/javascript"></script>
	<style type="text/css">
	.log{
		background-color: red
	}
	.log_done{
		background-color: #EEEEEE
	}
	</style>    
</head>
<body>



<fieldset id='step4' style="display: none">
<legend>STEP 4</legend>
<button onclick="insert()" id="btn_insert">Insert</button> some basic datas to the database.
<div id='log_insert' class='log'></div>
</fieldset>

<fieldset id='step5' style="display: none">
<legend>STEP 5</legend>
Political Zone Code(<a href='http://www.stats.gov.cn/tjbz/xzqhdm/t20130118_402867249.htm' target='_blank'>What's this?</a>):<input id='zone' /><br/>
<button onclick="simulate()" id="btn_simulate">Simulate</button> a lot of datas to the database. This will take a lot of time. You may skip this step .
<div id='log_simulate' class='log'></div>
</fieldset>

<script type="text/javascript">



/**
 * 初始化基础业务数据,包括:
 * 标准体系的数据字典,比如 行政区划编码 行业分类编码 会计分类编码 学科分类编码 高等院校编码  等等
 * 基础业务数据,比如 权限 用户组 用户组-权限 系统用户 等等
 * */
var insert = function(){
	$('#btn_insert').attr("disabled",true);
	$.ajax({
		url: "../aspx/install.aspx?class=install&function=init_data_excel__group"
		,dataType: 'json'
        ,type: "POST"		
        ,data: {
			 executor: ""
			,session: ""

        }         
		,success : function(response) {
			$('#log_insert').append(response.msg+"<br/>");
			if(response.status=="1"){
				$('#btn_insert').attr("disabled",true);
				$('#log_insert').attr("class","log_done");
				$('#step5').css("display","block");
			}else{
				$('#btn_insert').attr("disabled",false);
			}
		}
		,error : function(response){				
			alert("net error");
			$('#btn_insert').attr("disabled",false);
		}
	});	
}

var step = 0;
var urls = [
 "../aspx/install.aspx?class=install&function=init_data__group"
,"../aspx/install.aspx?class=install&function=init_data__user"

];


var simulate = function(){
	$('#btn_simulate').attr("disabled",true);
	$.ajax({
		url: urls[step]
		,dataType: 'json'
        ,type: "POST"		
        ,data: {
			 executor: ""
			,session: ""
			,zone: $('#zone').val()
        }         
		,success : function(response) {
			$('#log_simulate').append(response.msg+"<br/>");
			if(response.status=="1"){
				$('#btn_simulate').attr("disabled",true);
				$('#log_simulate').attr("class","log_done");

				if(step==7)return;
				step++;				
				simulate();
			}else{
				$('#btn_simulate').attr("disabled",false);
			}
		}
		,error : function(response){				
			alert("net error");
			$('#btn_simulate').attr("disabled",false);
		}
	});	
}
</script> 
</body>
</html>